using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Plugin.Sns.Scene;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.Manager
{
	public class TimeLineMgr
	{
		private static List<ulong> list_0 = new List<ulong>();
		public static void checkSnsObject(ulong objectID)
		{
			TimeLineMgr.checkSnsObjectFile(objectID);
			EventCenter.registerEventHandler(EventConst.ON_STORAGE_SNSINFO_ADD, new EventHandlerDelegate(TimeLineMgr.onCheckSnsObject));
			EventCenter.registerEventHandler(EventConst.ON_STORAGE_SNSINFO_MODIFY, new EventHandlerDelegate(TimeLineMgr.onCheckSnsObject));
			TimeLineMgr.list_0.Add(objectID);
			NetSceneSnsDetail netSceneSnsDetail = new NetSceneSnsDetail();
			netSceneSnsDetail.doScene(objectID);
		}
		public static void checkSnsObjectFile(ulong objectID)
		{
			byte[] array = StorageIO.readFromFile("tmp/" + objectID);
			if (array == null)
			{
				return;
			}
			TimeLineObject.ParseFrom(array);
		}
		private static void onCheckSnsObject(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			List<SnsInfo> listObject = evtArgs.getListObject<SnsInfo>();
			using (List<SnsInfo>.Enumerator enumerator = listObject.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					SnsInfo current = enumerator.get_Current();
					if (TimeLineMgr.list_0.Contains(current.nObjectID))
					{
						TimeLineMgr.list_0.Remove(current.nObjectID);
						TimeLineObject.dumpXmlData(current.bytesObjectDesc);
						if (TimeLineObject.ParseFrom(current.bytesObjectDesc) == null)
						{
							StorageIO.writeToFile("tmp/" + current.nObjectID, current.bytesObjectDesc, true);
							TimeLineObject.dumpXmlData(current.bytesObjectDesc);
							DebugEx.debugBreak();
						}
					}
				}
			}
		}
		public static void test()
		{
			TimeLineMgr.checkSnsObject(11281241732273737730uL);
		}
	}
}
